package com.qidi.ssh.dao;

import com.qidi.ssh.bean.User;
import com.qidi.ssh.utils.MD5Utils;
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;

import java.util.List;

/**
 * @author zhouXinBin
 * @create 2020-10-16-11:57
 */
public class UserDaoimpl extends BaseDaoimpl<User>  implements UserDao {

    public UserDaoimpl() {
        super(User.class);
    }

    @Override
    public User checkUserByUsername(String Usercode) {
        List<User> list = (List<User>) this.getHibernateTemplate().find("from User where user_code=?", Usercode);
        if(list!=null && list.size()>0) {
            return list.get(0);
        }
        return null;
    }

    @Override
    public User getUserByCodeAndPassword(User user) {
        List<User> list = (List<User>) this.getHibernateTemplate().find("from User where user_code=? and user_password=?", user.getUser_code(), user.getUser_password());
        if (list!=null && list.size()>0){
            User user1 = list.get(0);
            return user1;
        }
        return null;
    }
}
